home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / patch / common.h < prev    next >
C/C++ Source or Header  |  1994-08-18  |  4KB  |  178 lines

  1. /* $Header: /home/dice/com/src/patch/RCS/common.h,v 30.8 1994/08/18 05:51:51 dice Exp dice $
  2.  *
  3.  * $Log: common.h,v $
  4.  * Revision 30.8  1994/08/18  05:51:51  dice
  5.  * .
  6.  *
  7.  * Revision 30.0  1994/06/10  18:08:48  dice
  8.  * .
  9.  *
  10.  * Revision 30.0  1994/06/10  18:08:48  dice
  11.  * .
  12.  *
  13.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  14.  * patch12: sprintf was declared wrong
  15.  *
  16.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  17.  * patch10: support for shorter extensions.
  18.  *
  19.  * Revision 2.0  86/09/17  15:36:39  lwall
  20.  * Baseline for netwide release.
  21.  *
  22.  */
  23.  
  24. #define DEBUGGING
  25.  
  26. #define VOIDUSED 7
  27. #include "config.h"
  28.  
  29. /* shut lint up about the following when return value ignored */
  30.  
  31. #define Signal (void)signal
  32. #define Unlink (void)unlink
  33. #define Lseek (void)lseek
  34. #define Fseek (void)fseek
  35. #define Fstat (void)fstat
  36. #define Pclose (void)pclose
  37. #define Close (void)close
  38. #define Fclose (void)fclose
  39. #define Fflush (void)fflush
  40. #define Sprintf (void)sprintf
  41. #define Mktemp (void)mktemp
  42. #define Strcpy (void)strcpy
  43. #define Strcat (void)strcat
  44.  
  45. #include <stdio.h>
  46. #include <assert.h>
  47. #include <sys/types.h>
  48. #include <sys/stat.h>
  49. #include <ctype.h>
  50. #include <signal.h>
  51.  
  52. /* constants */
  53.  
  54. #define TRUE (1)
  55. #define FALSE (0)
  56.  
  57. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  58. #define INITHUNKMAX 125         /* initial dynamic allocation size */
  59. #define MAXLINELEN 1024
  60. #define BUFFERSIZE 1024
  61. #define SCCSPREFIX "s."
  62. #define GET "get -e %s"
  63. #define RCSSUFFIX ",v"
  64. #define CHECKOUT "co -l %s"
  65.  
  66. #ifdef FLEXFILENAMES
  67. #define ORIGEXT ".orig"
  68. #define REJEXT ".rej"
  69. #else
  70. #ifdef AMIGA
  71. #define ORIGEXT "@"
  72. #define REJEXT "%"
  73. #else
  74. #define ORIGEXT "~"
  75. #define REJEXT "#"
  76. #endif
  77. #endif
  78.  
  79. /* handy definitions */
  80.  
  81. #define Null(t) ((t)0)
  82. #define Nullch Null(char *)
  83. #define Nullfp Null(FILE *)
  84. #define Nulline Null(LINENUM)
  85.  
  86. #define Ctl(ch) ((ch) & 037)
  87.  
  88. #define strNE(s1,s2) (strcmp(s1, s2))
  89. #define strEQ(s1,s2) (!strcmp(s1, s2))
  90. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  91. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  92.  
  93. /* typedefs */
  94.  
  95. typedef char bool;
  96. typedef long LINENUM;            /* must be signed */
  97. typedef unsigned MEM;            /* what to feed malloc */
  98.  
  99. /* globals */
  100.  
  101. EXT int Argc;                /* guess */
  102. EXT char **Argv;
  103. EXT int Argc_last;            /* for restarting plan_b */
  104. EXT char **Argv_last;
  105.  
  106. EXT struct stat filestat;        /* file statistics area */
  107. EXT int filemode INIT(0644);
  108.  
  109. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  110. EXT FILE *ofp INIT(Nullfp);             /* output file pointer */
  111. EXT FILE *rejfp INIT(Nullfp);           /* reject file pointer */
  112.  
  113. EXT bool using_plan_a INIT(TRUE);       /* try to keep everything in memory */
  114. EXT bool out_of_mem INIT(FALSE);        /* ran out of memory in plan a */
  115.  
  116. #define MAXFILEC 2
  117. EXT int filec INIT(0);                  /* how many file arguments? */
  118. EXT char *filearg[MAXFILEC];
  119. EXT bool ok_to_create_file INIT(FALSE);
  120. EXT char *bestguess INIT(Nullch);       /* guess at correct filename */
  121.  
  122. EXT char *outname INIT(Nullch);
  123. EXT char rejname[128];
  124.  
  125. EXT char *origext INIT(Nullch);
  126. EXT char *origprae INIT(Nullch);
  127.  
  128. EXT char *TMPOUTNAME;
  129. EXT char *TMPINNAME;
  130. EXT char *TMPREJNAME;
  131. EXT char *TMPPATNAME;
  132. EXT bool toutkeep INIT(FALSE);
  133. EXT bool trejkeep INIT(FALSE);
  134.  
  135. EXT LINENUM last_offset INIT(0);
  136. #ifdef DEBUGGING
  137. EXT int debug INIT(0);
  138. #endif
  139. EXT LINENUM maxfuzz INIT(2);
  140. EXT bool force INIT(FALSE);
  141. EXT bool verbose INIT(TRUE);
  142. EXT bool reverse INIT(FALSE);
  143. EXT bool noreverse INIT(FALSE);
  144. EXT bool skip_rest_of_patch INIT(FALSE);
  145. EXT int strippath INIT(957);
  146. EXT bool canonicalize INIT(FALSE);
  147.  
  148. #define CONTEXT_DIFF 1
  149. #define NORMAL_DIFF 2
  150. #define ED_DIFF 3
  151. #define NEW_CONTEXT_DIFF 4
  152. #define UNI_DIFF 5
  153. EXT int diff_type INIT(0);
  154.  
  155. EXT bool do_defines INIT(FALSE);        /* patch using ifdef, ifndef, etc. */
  156. EXT char if_defined[128];        /* #ifdef xyzzy */
  157. EXT char not_defined[128];        /* #ifndef xyzzy */
  158. EXT char else_defined[] INIT("#else\n");/* #else */
  159. EXT char end_defined[128];        /* #endif xyzzy */
  160.  
  161. EXT char *revision INIT(Nullch);        /* prerequisite revision, if any */
  162.  
  163. char *malloc();
  164. char *realloc();
  165. char *strcpy();
  166. char *strcat();
  167. long atol();
  168. long lseek();
  169. char *mktemp();
  170. #ifdef CHARSPRINTF
  171. char *sprintf();
  172. #else
  173. #ifndef _DCC
  174. int sprintf();
  175. #endif
  176. #endif
  177. char *getenv();
  178.